﻿<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <variable name="relaxed"
              value="${longdate} | ${level:uppercase=true:padding=-5} | ${callsite} | ${message}"
    />

    <!-- Useful renderers

     ${callsite} - The call site (class name, method name and source information)
     ${callsite-filename} - The call site source file name.
     ${callsite-linenumber} - The call site source line number.
     ${exception} - Exception information provided through a call to one of the Logger methods
     ${exceptiondata} - Lookup item in Exception.Data-Dictionary from Exception provided together with the LogEven
     ${literal} - A string literal. (text) - useful to escape brackets
     ${newline} - A newline literal.
     ${stacktrace} - Render the Stack trace
     ${var} - Render variable

    -->

    <!-- Useful targets

     AutoFlushWrapper -  Causes a flush after each write on a wrapped target.
     Debugger - Writes log messages to the attached debugger through System.Diagnostics.Debugger.Log
     DebugSystem - Sends log messages through System.Diagnostics.Debug.
     ETW - Log to Event Tracing for Windows (ETW) package NLog.ETW
     EventLog - Writes log message to the Windows Event Log. package NLog.WindowsEventLog
     FormControl - Logs text to Windows.Forms.Control.Text property control of specified Name. package NLog.Windows.Forms
     MessageBox - Pops up log messages as message boxes. package NLog.Windows.Forms
     NLogViewer - Sends log messages to the remote instance of NLog Viewer.
     Null - Discards log messages. Used mainly for debugging and benchmarking.
     RichTextBox - Log text a Rich Text Box control in an existing or new form. package NLog.Windows.Forms
     Syslog - Writes NLog messages to Syslog package NLog.Targets.Syslog External
     ToolStripItem - Logs text to Windows.Forms.ToolStripItem property control of specified Name package NLog.Windows.Forms
     Trace - Sends log messages through System.Diagnostics.Trace.

    -->

    <targets>

        <target xsi:type="EventLog"
                name="eventlog"
                layout="${level:uppercase=true}: ${message}"
                machineName="."
                source="ApplicationName"
                log="Application"
                eventId="1"
                maxKilobytes="4096"
                maxMessageLength="1024"
        />

        <target name="logconsole" xsi:type="ColoredConsole"
                layout="${relaxed}"
        />

        <target name="debuglog" xsi:type="File"
                layout="${relaxed}"
                fileName="LogFile.txt"
        />

        <!-- автоматическая ежедневная ротация log-файлов -->
        <target name="rotated" xsi:type="File"
                layout="${relaxed}"
                archiveFileName="LogFile-{#}.txt"
                archiveNumbering="Date"
                archiveEvery="Day"
                archiveDateFormat="yyyyMMdd"
                fileName="LogFile.txt"
        />

        <!-- C:\Users\UserName\AppData\Roaming\Ars Magna\ApplicationName -->
        <target name="productionlog" xsi:type="File"
                layout="${relaxed}"
                fileName="${specialfolder:folder=CommonApplicationData}/Ars Magna/ApplicationName/LogFile.txt"
        />

        <target name="magnalog" xsi:type="Magna"
                layout="${relaxed}"
        />

    </targets>

    <rules>
        <logger name="*" minlevel="Debug" writeTo="logconsole" />
        <logger name="*" minlevel="Debug" writeTo="productionlog" />
    </rules>

</nlog>
